<?php
require_once 'Response.php';
require_once 'DB.php';
header('Content-Type:text/json;charset=utf-8');
# 设置允许跨域
header("Access-Control-Allow-Origin: *");
$username=empty($_REQUEST['username'])?'':$_REQUEST['username'];
$password=empty($_REQUEST['pwd'])?'':$_REQUEST['pwd'];

$pdo = DB::getInstance()->connect();

$sql="SELECT * FROM admin WHERE name='$username' ";
$stmt=$pdo->query($sql);
$user=$stmt->fetch();

if(empty($user)){
    Response::json('-1','没有这人');

}
if($user['password']==$password){
    Response::json('200','登录成功',$user);
    session_start();
    $_SESSION['username']=$username;

}else{
    Response::json('-2','我又不记得你密码');
}
